import {BasePage, BasePageData} from "../common/core/BasePage";
import {DataLoader, field} from "../../modules/coreModule/data/DataLoader";
import {page, pageFunc} from "../common/PageBuilder";
import {UserPage} from "../common/partPages/UserPage";
import {QueryPage} from "../common/partPages/QueryPage";
import {waitForLogin} from "../../modules/userModule/managers/UserManager";
import {Banner, bannerRepo} from "../../modules/miscModule/data/Banner";
import {PK} from "../../modules/coreModule/data/BaseData";
import {Notice, noticeRepo} from "../../modules/messageModule/data/Notice";

class Data extends BasePageData {

    @field(Banner)
    banner: Banner
    @field(Notice)
    notice: Notice
}

class Param {
    bannerId?: PK
    noticeId?: PK
}

@page("bannerDetail", "轮播图详情页")
export class BannerDetailPage extends BasePage<Data, Param> {

    public data = new Data();

    /**
     * 部分页
     */
    public userPage: UserPage = new UserPage();

    onLoad(e) {
        super.onLoad(e);
        const {bannerId, noticeId} = this.params;
        const banner = bannerId && bannerRepo().doc(bannerId);
        const notice = noticeId && noticeRepo().doc(noticeId);
        this.setData({ banner, notice })
    }
}
